<template>
  <a-modal v-model:visible="showDialog" hide-title simple width="360" @ok="delItem" @cancel="delCancel">
    <div class="del-content">删除该任务会同步删除所有的在途待办任务， 请确认是否继续？</div>
  </a-modal>
</template>
<script setup lang="ts">
import {deleteProcessTask,deleteStageTask} from "@/apis/system";
import { Message } from "@arco-design/web-vue";


const props = defineProps({
  currentTaskSettingId: {
    type: String,
    default: ''
  },
  currentPortraitId: {
    type: String,
    default: ''
  },
  stageSettingId: {
    type: String,
    default: ''
  },
  currentDeleteType: {
    type: String,
    default: ''
  }
})
const $emit = defineEmits(["handleDelete"])

const showDialog = ref(true);
const delItem = async () => {
  // console.log(props.currentTaskSettingId)
  // console.log("11")
  try {
    if(props.currentDeleteType === 'task'){
      await deleteProcessTask(props.currentTaskSettingId);
    }
    if(props.currentDeleteType === 'stage'){
      await deleteStageTask(props.currentPortraitId,props.stageSettingId)
    }
    Message.success("删除成功");
    showDialog.value = false
    $emit("handleDelete",'confirm')
  }catch {
    showDialog.value = false
    $emit("handleDelete",'cancel')
  }

};

const delCancel = ()=>{
   showDialog.value = false
  $emit("handleDelete",'cancel')
}
</script>

<style scoped lang="scss">
@import "../process";
</style>